//
//  TabBarButton.m
//  Project1
//
//  Created by 黄珂耀 on 15/7/17.
//  Copyright (c) 2015年 黄珂耀. All rights reserved.
//

#import "TabBarButton.h"
#import "common.h"

@implementation TabBarButton

- (id)initWithFrame:(CGRect)frame andImageName:(NSString *)imageName andTitle:(NSString *)title
{
    self = [super initWithFrame:frame];
    if (self)
    {
        
        _imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [_imageView setImage:[UIImage imageNamed:imageName]];
        _imageView.contentMode = UIViewContentModeScaleAspectFit;
        
        [self addSubview:_imageView];
        
        _label = [[UILabel alloc] initWithFrame:CGRectZero];
        _label.text = title;
        _label.textAlignment = NSTextAlignmentCenter;
        _label.font = [UIFont systemFontOfSize:11];
        _label.textColor = [UIColor whiteColor];
        
        [self addSubview:_label];
    }
    
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _imageView.frame = CGRectMake((KWidth / 5 - 20) / 2, 5, 20, 20);
    _label.frame = CGRectMake(0, CGRectGetMaxY(_imageView.frame), KWidth / 5, 20);
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
